package Thread;

import java.util.Scanner;

public class ThreadDemo16 {

    private volatile static int flag = 0;

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            while (flag == 0) {

            }
            System.out.println("t1线程结束");
        });

        Thread t2 = new Thread(() -> {
            System.out.println("输入flag值：");
            Scanner scanner = new Scanner(System.in);
            flag = scanner.nextInt();
        });

        t1.start();;
        t2.start();
    }

}
